package com.orhon.smartcampus.modules.teacher.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.*;

import com.orhon.smartcampus.modules.base.entity.Grades;
import com.orhon.smartcampus.modules.base.entity.Periods;
import com.orhon.smartcampus.modules.base.entity.Subjects;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import com.orhon.smartcampus.modules.base.entity.Schools;
import com.orhon.smartcampus.modules.user.entity.Users;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "teacher_information", schema = "smartcloud", catalog = "")
public class TInformation {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;
    
    @Column(name = "idcard", nullable = true, length = 255)
    private String idcard;
    
    @Column(name = "gender", nullable = true, length = 255)
    private String gender;
    
    @Column(name = "birthday", nullable = true, length = 255)
    private String birthday;
    
    @Column(name = "nativeprovince", nullable = true, length = 255)
    private Integer nativeprovince;
    
    @Column(name = "nativecity", nullable = true, length = 255)
    private Integer nativecity;
    
    @Column(name = "nativecounty", nullable = true, length = 255)
    private Integer nativecounty;
    
    @Column(name = "birthprovince", nullable = true, length = 255)
    private Integer birthprovince;
    
    @Column(name = "birthcity", nullable = true, length = 255)
    private Integer birthcity;
    
    @Column(name = "birthcounty", nullable = true, length = 255)
    private Integer birthcounty;
    
    @Column(name = "type", nullable = true, length = 255)
    private String type;
    
//    @Column(name = "unitname", nullable = true, length = 255)
//    private Integer unitname;
    
    @Column(name = "email", nullable = true, length = 255)
    private String email;
    
    @Column(name = "telnumber", nullable = true, length = 255)
    private String telnumber;
    
    @Column(name = "nationality", nullable = true, length = 255)
    private String nationality;
    
    @Column(name = "politicaltype", nullable = true, length = 255)
    private String politicaltype;
    
    @Column(name = "workstatus", nullable = true, length = 255)
    private String workstatus;
    
    @Column(name = "workdate", nullable = true, length = 255)
    private String workdate;
    
    @Column(name = "jobtitle", nullable = true, length = 255)
    private String jobtitle;
    
    @Column(name = "education", nullable = true, length = 255)
    private String education;
    
    @Column(name = "degree", nullable = true, length = 255)
    private String degree;
    
    @Column(name = "mastersupervisor", nullable = true, length = 255)
    private String mastersupervisor;
    
    @Column(name = "teach", nullable = true, length = 255)
    private String teach;
    
    @Column(name = "talentcategory_six", nullable = true, length = 255)
    private String talentcategorySix;
    
    @Column(name = "talentcategory_nine", nullable = true, length = 255)
    private String talentcategoryNine;
    
    @Column(name = "cmbprovince3", nullable = true)
    private Integer cmbprovince3;
    
    @Column(name = "cmbcity3", nullable = true)
    private Integer cmbcity3;
    
    @Column(name = "cmbcounty3", nullable = true)
    private Integer cmbcounty3;
    
    @Column(name = "cmbprovince2", nullable = true)
    private Integer cmbprovince2;
    
    @Column(name = "cmbcity2", nullable = true)
    private Integer cmbcity2;
    
    @Column(name = "cmbcounty2", nullable = true)
    private Integer cmbcounty2;
    
    @Column(name = "created_at", nullable = true)
    private Date createdAt;
    
    @Column(name = "created_by", nullable = true)
    private Integer createdBy;
    
    @Column(name = "updated_at", nullable = true)
    private Date updatedAt;
    
    @Column(name = "updated_by", nullable = true)
    private Integer updatedBy;
    
    @Column(name = "deleted_at", nullable = true)
    private Date deletedAt;
    
    @Column(name = "nation", nullable = true)
    private String nation;
    
    @Column(name = "imgphotos", nullable = true)
    private String imgphotos;
    
    @Column(name = "signimg", nullable = true)
    private String signimg;
    
    @Column(name = "teacher_name", nullable = true)
    private String teacherName;
    
    @Column(name = "introduction", nullable = true)
    private String introduction;


    @ManyToOne
    @JoinColumn(name = "user_id", referencedColumnName = "id")
    @NotFound(action=NotFoundAction.IGNORE)
    @Where(clause = "ISNULL(deleted_at)")
    private Users userUsersByUserId;

    @ManyToOne
    @JoinColumn(name = "school_id", referencedColumnName = "id")
    @NotFound(action=NotFoundAction.IGNORE)
    @Where(clause = "ISNULL(deleted_at)")
    private Schools baseSchoolsBySchoolId;

    //学科
    //@JsonIgnoreProperties("subjects")
    @ManyToMany(cascade = CascadeType.ALL,  fetch = FetchType.LAZY)
    @JoinTable(
            name = "base_teacher_subjects_relation",
            joinColumns = { @JoinColumn(name = "teacher_id")},
            inverseJoinColumns = { @JoinColumn(name = "subjects_id")}
    )
    @NotFound(action= NotFoundAction.IGNORE)
    @Where(clause = "ISNULL(deleted_at)")
    List<Subjects> subjects;

    //年级
    @ManyToMany(cascade = CascadeType.ALL,  fetch = FetchType.LAZY)
    @JoinTable(
            name = "base_teacher_grades_relation",
            joinColumns = { @JoinColumn(name = "teacher_id")},
            inverseJoinColumns = { @JoinColumn(name = "grades_id")}
    )
    @NotFound(action= NotFoundAction.IGNORE)
    @Where(clause = "ISNULL(deleted_at)")
    List<Grades> grades;


    //学段
    //@JsonIgnoreProperties("subjects")
    @ManyToMany(cascade = CascadeType.ALL,  fetch = FetchType.LAZY)
    @JoinTable(
            name = "base_teacher_periods_relation",
            joinColumns = { @JoinColumn(name = "teacher_id")},
            inverseJoinColumns = { @JoinColumn(name = "period_id")}
    )
    @NotFound(action= NotFoundAction.IGNORE)
    @Where(clause = "ISNULL(deleted_at)")
    List<Periods> periods;

}
